/*
-----------------------------------------------------------------------------
This source file is part of Glare3D
(The Graphics Library Abstract Rendering Engine)
For the latest info, see http://code.google.com/p/glare3d/

Copyright (c) 2012 Fuse-Software (tm)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/

#ifndef __glare_gles2_FormatMapping_h__
#define __glare_gles2_FormatMapping_h__

#include "glare.gles2.Prerequisites.h"
#include "Glare.Core.GpuPrimitiveType.h"

namespace Glare {

	class GLES2FormatMapping
	{
	public : static GLint MapElementCount(PixelFormat pf)
			 {
				 switch (pf)
				 {
				 case PF_R32G32_FLOAT:		return 2;
				 case PF_R32G32B32_FLOAT:	return 3;
				 default:					return 0;
				 }
			 }

	public : static GLenum MapType(PixelFormat pf)
			 {
				 switch (pf)
				 {
				 case PF_R32G32_FLOAT:		return GL_FLOAT;
				 case PF_R32G32B32_FLOAT:	return GL_FLOAT;
				 default:					return GL_NONE;
				 }
			 }

	public : static GLenum MapPrimitive(const GpuPrimitive::Type& primitive_type)
			 {
				 switch (primitive_type)
				 {
				 case GpuPrimitive::TriangleList:	return GL_TRIANGLES;
				 case GpuPrimitive::TriangleStrip:	return GL_TRIANGLE_STRIP;
				 default:							return GL_NONE;
				 }
			 }

	public : static uint GetUniformTypeSize(const GLenum& uniform_type)
			 {
				 switch (uniform_type)
				 {
				 case GL_FLOAT:			return 4; break;
				 case GL_FLOAT_VEC2:	return 8; break;
				 case GL_FLOAT_VEC3:	return 12; break;
				 case GL_FLOAT_VEC4:	return 16; break;
				 case GL_INT:			return 4; break;
				 case GL_INT_VEC2:		return 8; break;
				 case GL_INT_VEC3:		return 12; break;
				 case GL_INT_VEC4:		return 16; break;
				 case GL_BOOL:			return 4; break;
				 case GL_BOOL_VEC2:		return 8; break;
				 case GL_BOOL_VEC3:		return 8; break;
				 case GL_BOOL_VEC4:		return 8; break;
				 case GL_FLOAT_MAT2:	return 16; break;
				 case GL_FLOAT_MAT3:	return 36; break;
				 case GL_FLOAT_MAT4:	return 64; break;
					 //case GL_SAMPLER_1D:
				 case GL_SAMPLER_2D:	return (uint)-1;
					 //case GL_SAMPLER_3D:
				 case GL_SAMPLER_CUBE:	return (uint)-1;
					 //case GL_SAMPLER_1D_SHADOW:
					 //case GL_SAMPLER_2D_SHADOW:
				 default: return (uint)-1; break;
				 }
			 }
	};

}

#endif // __glare_gles2_FormatMapping_h__
